
#ifndef STATEMANAGER_H
#define STATEMANAGER_H

#include <vector>
#include "Singleton.h"
#include "GameState.h"
#include "RenderableEntity.h"
#include "FadeEffect.h"

class StateManager : public Singleton<StateManager>
{
private:
    std::vector<GameState*> m_vStates;
    
    enum eStateOperation { None, PushState, SetState, PopState, PopStateUntil };
    eStateOperation m_eCurrentOperation;
	GameState* m_gsNewState;
    
    RenderableEntity* m_reFade;
    FadeEffect* m_feFade;

    void manageStateChange();

public:
    
	StateManager();
	~StateManager();
    
    void init();
	void update(float dt);
	void render();
    
    //State management
    void setState(GameState& newState);
    void pushState(GameState& newState);
    void popState();
    void popStateUntil(GameState& newState);
    
    void pause(bool _bValue = true);
    
    //Fade
    void setupFade();
    void fadeIn(float _fTime = 0.2f);
    void fadeOut(float _fTime = 0.2f);
    bool isFading();
    
};

#endif
